<template>
  <!-- PC端navBar -->
  <div class="hidden-sm-and-down" id="navBarBox"
       style="backdrop-filter: blur(5px);position: sticky;top: 0;left: 0;width: 100%;height: 51px;
       transition: all .35s ease;
       z-index: 100;
       padding: 0 10px;">
    <el-row class="navBar" style="height: 51px;border-bottom: 1px solid var(--text-primary-color)">
      <el-col class="navBar-item" :span="4" style="display: flex;justify-content: center;align-items: center;">
        <button class="button" data-text="Awesome">
          <span class="actual-text">&nbsp;LKZYBlog&nbsp;</span>
          <span aria-hidden="true" class="hover-text">&nbsp;LKZYBlog&nbsp;</span>
        </button>
      </el-col>
      <el-col class="navBar-item" :span="5"
              style="padding:5px;display: flex;align-items: center;justify-content: center;">
        <div class="searchBox"
             style="width:auto;height:100%;background-color: var(--active-color-2);display: flex;border-radius: 20px;
             overflow: hidden;border: 1px solid var(--active-border-color)">
          <el-icon class="searchIcon" @click="searchInputPCOpen = !searchInputPCOpen"
                   style="cursor: pointer;width: 40px;height: 40px;line-height: 40px;border-radius: 50%">
            <Close v-if="searchInputPCOpen"/>
            <Search v-else/>
          </el-icon>
          <input :class="{ 'searchInputPC': true, 'searchInputPCOpen': searchInputPCOpen }"
                 placeholder="输入文章信息..."
                 style="background-color:transparent;height: 100%"/>

          <el-icon v-if="searchInputPCOpen" class="searchBtn"
                   style="color: var(--active-color-1-text);width: 40px;height: 40px;cursor: pointer;border-radius: 50%;background-color: var(--active-color-1)">
            <Search/>
          </el-icon>
        </div>
      </el-col>
      <el-col class="navBar-item" :span="12">
        <ul style="display: flex;">
          <li class="navBar-li"><span>🏡首页</span></li>
          <li class="navBar-li"><span>🏷️标签</span></li>
          <li class="navBar-li"><span>🎮生活</span></li>
          <li class="navBar-li"><span>🗂️归档</span></li>
          <li class="navBar-li"><span>📪留言板</span></li>
          <li class="navBar-li"><span>💘LOVE</span></li>
          <li class="navBar-li"><span>💵赞助</span></li>
        </ul>
      </el-col>
      <el-col class="navBar-item" :span="2" style="display: flex;justify-content: center;align-items: center;">
        <ThemeToggleButton style="--toggle-size: 0.38rem"/>
      </el-col>
      <el-col class="navBar-item" :span="1" style="display: flex;justify-content: center;align-items: center;">
      </el-col>

    </el-row>
  </div>
  <NavBarToggle @change="toggleNavBar" class="hidden-sm-and-down navBarToggle"
                style="position: fixed;right: 15px;top: 8px;z-index: 101"/>

  <!-- 移动端navBar -->
  <div :class="['hidden-md-and-up','sm-navBarBox', {'sm-navBarBoxOpen': !smallNavBarHidden}]">
    <div style="width: 95%;height: 90%;">

      <!-- ThemeToggleButtonBox -->
      <div class="ThemeToggleButtonBox"
           style="position: absolute;left: 10px;top:15px;margin-bottom:5px;display: flex;justify-content: center;align-items: center">
        <div>
          <ThemeToggleButton style="--toggle-size: .5rem"/>
        </div>
      </div>

      <!-- sm-searchBox -->
      <div class="sm-searchBox" style="width: 100%;">
        <div class="form-control" style=" margin: 30px auto 0;position: relative;">
          <input type="value" required="">
          <label>
            <span style="transition-delay:0ms">搜</span>
            <span style="transition-delay:50ms">索</span>
            <span style="transition-delay:100ms">文</span>
            <span style="transition-delay:150ms">章</span>
            <span style="transition-delay:200ms">.</span>
            <span style="transition-delay:250ms">.</span>
            <span style="transition-delay:300ms">.</span>
          </label>
          <div style="background-color: var(--active-border-color);right: 0;bottom: 0;width: auto;position: absolute">
            <el-icon style="width: 2rem;height: 2rem;line-height: 2rem;font-size: 1.5rem;margin: 5px">
              <Search/>
            </el-icon>
          </div>

        </div>

      </div>


      <!-- codeBox -->
      <div class="codeBox" style="width: 100%;margin: 10px 0;">
        <div class="terminal-loader">
          <div class="terminal-header">
            <div class="terminal-title">欢迎浏览</div>
            <div class="terminal-controls">
              <div class="control close"></div>
              <div class="control minimize"></div>
              <div class="control maximize"></div>
            </div>
          </div>
          <div class="text">掠空之翼博客...</div>
        </div>

      </div>

      <!-- itemBox -->
      <div class="" style="width: 100%;">
        <ul style="display: flex;flex-direction: column">
          <li class="sm-nav-item"><span>🏡首&nbsp;&nbsp;&nbsp;&nbsp;页</span></li>
          <li class="sm-nav-item"><span>🏷️标&nbsp;&nbsp;&nbsp;&nbsp;签</span></li>
          <li class="sm-nav-item"><span>🎮生&nbsp;&nbsp;&nbsp;&nbsp;活</span></li>
          <li class="sm-nav-item"><span>🗂️归&nbsp;&nbsp;&nbsp;&nbsp;档</span></li>
          <li class="sm-nav-item"><span>📪留言板</span></li>
          <li class="sm-nav-item"><span>💘LOVE</span></li>
          <li class="sm-nav-item"><span>💵赞&nbsp;&nbsp;&nbsp;&nbsp;助</span></li>
        </ul>
      </div>

    </div>

  </div>
  <div class="hidden-md-and-up sm-navBarToggle" @click="smallToggleNavBar"
       style="position: fixed;right: 15px;top: 10px;z-index: 100;">
    <input type="checkbox" id="checkbox" :checked="!smallNavBarHidden">
    <label for="checkbox" class="toggle">
      <div class="bars" id="bar1"></div>
      <div class="bars" id="bar2"></div>
      <div class="bars" id="bar3"></div>
    </label>
  </div>


  <!-- 主体 -->
  <el-container>
    <el-main style="padding: 0;margin-top: 10px;">
      <router-view></router-view>
    </el-main>
  </el-container>
</template>


<script>

import ThemeToggleButton from '@/components/ThemeToggleButton.vue';
import NavBarToggle from "@/components/NavBarToggle.vue";
import {CircleClose, Close, CloseBold, Search} from "@element-plus/icons-vue";

export default {
  name: 'blog',
  components: {
    Close,
    CircleClose,
    CloseBold,
    Search,
    // 在components选项中注册导入的组件
    ThemeToggleButton,
    NavBarToggle
  },
  data() {
    return {
      searchInputPCOpen: false,
      smallNavBarHidden: true
    }
  },
  methods: {
    toggleNavBar() {
      document.getElementById("navBarBox").classList.toggle('navBarBoxHidden')
    },
    smallToggleNavBar() {
      this.smallNavBarHidden = !this.smallNavBarHidden
    }
  }
};
</script>

<style scoped>

/* LOGO开始 */
/* === removing default button style ===*/
.button {
  margin: 0;
  height: auto;
  background: transparent;
  padding: 0;
  border: none;
  cursor: pointer;
}

/* button styling */
.button {
  --border-right: 6px;
  --text-stroke-color: var(--text-primary-color);
  --animation-color: var(--active-border-color);
  --fs-size: 2em;
  letter-spacing: 3px;
  text-decoration: none;
  font-size: var(--fs-size);
  font-weight: bold;
  font-family: "Arial";
  position: relative;
  text-transform: uppercase;
  color: transparent;
  -webkit-text-stroke: 1px var(--text-stroke-color);
}

/* this is the text, when you hover on button */
.hover-text {
  position: absolute;
  box-sizing: border-box;
  content: attr(data-text);
  color: var(--animation-color);
  width: 0%;
  inset: 0;
  border-right: var(--border-right) solid var(--animation-color);
  overflow: hidden;
  transition: 0.5s;
  -webkit-text-stroke: 1px var(--animation-color);
}

/* hover */
.button:hover .hover-text {
  width: 100%;
  filter: drop-shadow(0 0 23px var(--animation-color))
}

/* LOGO结束 */
.navBar-item {
  height: 50px;
  line-height: 50px;
  text-align: center;
}

.navBarBoxHidden {
  opacity: 0;
  height: 0 !important;
}

.navBarToggle {
  opacity: 0.5;
  transition: opacity ease .2s;
}

.navBarToggle:hover {
  opacity: 1;
}

/* 搜索框开始 */
.searchInputPC {
  width: 0;
  opacity: 0;
  transition: all .35s ease;
}

.searchInputPCOpen, .searchInputPC:focus {
  opacity: 1;
  width: 120px !important;
}

.searchIcon {
  transition: font-size .2s ease;
}

.searchIcon:hover {
  font-size: 18px;
}

.searchBtn {
  transition: font-size ease .2s;
}

.searchBtn:hover {
  font-size: 19px;
}

/* 搜索框结束 */

/* navBar-li 开始*/
.navBar-li {
  flex: 1;
  cursor: pointer;
  transition: all .2s ease;
}

.navBar-li {
  position: relative;
}


.navBar-li > span:before {
  content: '';
  width: 0;
  height: 2px;
  background-color: var(--active-color-2);
  position: absolute;
  transition: all .35s ease;
  right: 0;
  top: 0;
}

.navBar-li > span:after {
  content: '';
  width: 0;
  height: 2px;
  background-color: var(--active-color-2);
  position: absolute;
  transition: all .35s ease;
  left: 0;
  bottom: 0;
}

.navBar-li:hover > span:before {
  width: 100%;
}

.navBar-li:hover > span:after {
  width: 100%;
}

.navBar-li:hover {
  background-color: var(--active-color-1);
  font-size: 17px;
  color: var(--active-color-1-text);
}

/* navBar-li 结束*/


/* 移动端navBar开始 */
.sm-navBarBox {
  width: 100vw;
  height: 100vh;
  background-color: var(--box-bg-color);
  position: fixed;
  left: 0;
  top: -100%;
  opacity: 0;
  transition: all .5s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 90;
}

.sm-navBarBoxOpen {
  overflow: hidden;
  opacity: 1;
  top: 0;
}

/* 移动端navBar结束 */


/* 移动端navBarToggle开始 */
#checkbox {
  display: none;
}

.toggle {
  position: relative;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition-duration: .5s;
}

.bars {
  width: 100%;
  height: 4px;
  background-color: var(--active-border-color);
  border-radius: 4px;
}

#bar2 {
  transition-duration: .8s;
}

#bar1, #bar3 {
  width: 70%;
}

#checkbox:checked + .toggle .bars {
  position: absolute;
  transition-duration: .5s;
}

#checkbox:checked + .toggle #bar2 {
  transform: scaleX(0);
  transition-duration: .5s;
}

#checkbox:checked + .toggle #bar1 {
  width: 100%;
  transform: rotate(45deg);
  transition-duration: .5s;
}

#checkbox:checked + .toggle #bar3 {
  width: 100%;
  transform: rotate(-45deg);
  transition-duration: .5s;
}

#checkbox:checked + .toggle {
  transition-duration: .5s;
  transform: rotate(180deg);
}

/* 移动端navBarToggle结束 */

/* 移动端navBar内容开始 */
@keyframes blinkCursor {
  50% {
    border-right-color: transparent;
  }
}

@keyframes typeAndDelete {
  0%,
  10% {
    width: 0;
  }
  45%,
  55% {
    width: 6.2em;
  }
  /* adjust width based on content */
  90%,
  100% {
    width: 0;
  }
}

.terminal-loader {
  border: 0.1em solid #333;
  background-color: #1a1a1a;
  color: #0f0;
  font-family: "Courier New", Courier, monospace;
  font-size: 1em;
  padding: 1.5em 1em;
  width: 12em;
  margin: 0 auto;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.terminal-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5em;
  background-color: #333;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  padding: 0 0.4em;
  box-sizing: border-box;
}

.terminal-controls {
  float: right;
}

.control {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-left: 0.4em;
  border-radius: 50%;
  background-color: #777;
}

.control.close {
  background-color: #e33;
}

.control.minimize {
  background-color: #ee0;
}

.control.maximize {
  background-color: #0b0;
}

.terminal-title {
  float: left;
  line-height: 1.5em;
  color: #eee;
}

.text {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  border-right: 0.2em solid green; /* Cursor */
  animation: typeAndDelete 4s steps(11) infinite,
  blinkCursor 0.5s step-end infinite alternate;
  margin-top: 1.5em;
}


/* 搜索框 */
.form-control {
  position: relative;
  margin: 20px 0 40px;
  width: 190px;
}

.form-control input {
  background-color: transparent;
  border: 0;
  border-bottom: 2px var(--active-border-color) solid;
  display: block;
  width: 100%;
  padding: 15px 0;
  font-size: 18px;
  color: var(--text-primary-color);
}

.form-control input:focus,
.form-control input:valid {
  outline: 0;
  border-bottom-color: var(--active-border-color);
}

.form-control label {
  position: absolute;
  top: 15px;
  left: 0;
  pointer-events: none;
}

.form-control label span {
  display: inline-block;
  font-size: 18px;
  min-width: 5px;
  color: var(--text-primary-color);
  transition: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.form-control input:focus + label span,
.form-control input:valid + label span {
  color: var(--active-border-color);
  transform: translateY(-30px);
}

.sm-nav-item {
  cursor: pointer;
  flex: 1;
  margin-bottom: 8px;
  padding: 10px 0;
  text-align: center;
  border-bottom: 2px solid var(--active-border-color);
  font-size: 2rem;
}

/* 移动端navBar内容结束 */
</style>